home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / russell / gc32.lha / config.h < prev    next >
C/C++ Source or Header  |  1993-07-29  |  13KB  |  420 lines

  1. #ifndef CONFIG_H
  2.  
  3. # define CONFIG_H
  4.  
  5. /* Machine dependent parameters.  Some tuning parameters can be found    */
  6. /* near the top of gc_private.h.                    */
  7.  
  8. /* Machine specific parts contributed by various people.  See README file. */
  9.  
  10. /* Determine the machine type: */
  11. # if defined(sun) && defined(mc68000)
  12. #    define M68K
  13. #    define SUNOS
  14. #    define mach_type_known
  15. # endif
  16. # if defined(hp9000s300)
  17. #    define M68K
  18. #    define HP
  19. #    define mach_type_known
  20. # endif
  21. # if defined(vax)
  22. #    define VAX
  23. #    ifdef ultrix
  24. #    define ULTRIX
  25. #    else
  26. #    define BSD
  27. #    endif
  28. #    define mach_type_known
  29. # endif
  30. # if defined(mips)
  31. #    define MIPS
  32. #    ifdef ultrix
  33. #    define ULTRIX
  34. #    else
  35. #    ifdef _SYSTYPE_SVR4
  36. #      define IRIX5
  37. #    else
  38. #      define RISCOS  /* or IRIX 4.X */
  39. #    endif
  40. #    endif
  41. #    define mach_type_known
  42. # endif
  43. # if defined(sequent) && defined(i386)
  44. #    define I386
  45. #    define SEQUENT
  46. #    define mach_type_known
  47. # endif
  48. # if defined(sun) && defined(i386)
  49. #    define I386
  50. #    define SUNOS5
  51. #    define mach_type_known
  52. # endif
  53. # if defined(__OS2__) && defined(__32BIT__)
  54. #    define I386
  55. #    define OS2
  56. #    define mach_type_known
  57. # endif
  58. # if defined(ibm032)
  59. #   define RT
  60. #   define mach_type_known
  61. # endif
  62. # if defined(sun) && defined(sparc)
  63. #   define SPARC
  64.     /* Test for SunOS 5.x */
  65. #     include <errno.h>
  66. #     ifdef ECHRNG
  67. #       define SUNOS5
  68. #     else
  69. #    define SUNOS4
  70. #     endif
  71. #   define mach_type_known
  72. # endif
  73. # if defined(_IBMR2)
  74. #   define IBMRS6000
  75. #   define mach_type_known
  76. # endif
  77. # if defined(SCO)
  78. #   define I386
  79. #   define SCO
  80. #   define mach_type_known
  81. /*    --> incompletely implemented */
  82. # endif
  83. # if defined(_AUX_SOURCE)
  84. #   define M68K
  85. #   define SYSV
  86. #   define mach_type_known
  87. # endif
  88. # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1)
  89. #   define HP_PA
  90. #   define mach_type_known
  91. # endif
  92. # if defined(linux) && defined(i386)
  93. #    define I386
  94. #    define LINUX
  95. #    define mach_type_known
  96. # endif
  97. # if defined(__alpha)
  98. #   define ALPHA
  99. #   define mach_type_known
  100. # endif
  101.  
  102. /* Feel free to add more clauses here */
  103.  
  104. /* Or manually define the machine type here.  A machine type is     */
  105. /* characterized by the architecture.  Some                */
  106. /* machine types are further subdivided by OS.                */
  107. /* the macros ULTRIX, RISCOS, and BSD to distinguish.            */
  108. /* Note that SGI IRIX is treated identically to RISCOS.            */
  109. /* SYSV on an M68K actually means A/UX.                    */
  110. /* The distinction in these cases is usually the stack starting address */
  111. # ifndef mach_type_known
  112.     --> unknown machine type
  113. # endif
  114.             /* Mapping is: M68K       ==> Motorola 680X0    */
  115.             /*           (SUNOS, HP, and SYSV (A/UX) variants)*/
  116.             /*             M68K_HP    ==> HP9000/300         */
  117.             /*           M68K_SYSV  ==> A/UX, maybe others    */
  118.             /*             I386       ==> Intel 386         */
  119.             /*            (SEQUENT, OS2, SCO, LINUX variants)    */
  120.             /*             SCO is incomplete.            */
  121.                     /*             NS32K      ==> Encore Multimax     */
  122.                     /*             MIPS       ==> R2000 or R3000    */
  123.                     /*            (RISCOS, ULTRIX variants)    */
  124.                     /*           VAX          ==> DEC VAX        */
  125.                     /*            (BSD, ULTRIX variants)        */
  126.                     /*           RS6000     ==> IBM RS/6000 AIX3.1    */
  127.                     /*           RT          ==> IBM PC/RT        */
  128.                     /*           HP_PA      ==> HP9000/700 & /800    */
  129.                     /*                  HP/UX            */
  130.             /*           SPARC      ==> SPARC under SunOS    */
  131.             /*            (SUNOS4, SUNOS5 variants)    */
  132.             /*            ALPHA      ==> DEC Alpha OSF/1    */
  133.  
  134.  
  135. /*
  136.  * For each architecture and OS, the following need to be defined:
  137.  *
  138.  * CPP_WORD_SZ is a simple integer constant representing the word size.
  139.  * in bits.  We assume byte addressibility, where a byte has 8 bits.
  140.  * We also assume CPP_WORD_SZ is either 32 or 64.  Only 32 is completely
  141.  * implemented.  (We care about the length of pointers, not hardware
  142.  * bus widths.  Thus a 64 bit processor with a C compiler that uses
  143.  * 32 bit pointers should use CPP_WORD_SZ of 32, not 64.)
  144.  *
  145.  * MACH_TYPE is a string representation of the machine type.
  146.  * OS_TYPE is analogous for the OS.
  147.  *
  148.  * ALIGNMENT is the largest N, such that
  149.  * all pointer are guaranteed to be aligned on N byte boundaries.
  150.  * defining it to be 1 will always work, but perform poorly.
  151.  *
  152.  * DATASTART is the beginning of the data segment.
  153.  * On UNIX systems, the collector will scan the area between DATASTART
  154.  * and &end for root pointers.
  155.  *
  156.  * STACKBOTTOM is the cool end of the stack, which is usually the
  157.  * highest address in the stack.
  158.  * Under PCR or OS/2, we have other ways of finding thread stacks.
  159.  * For each machine, the following should:
  160.  * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
  161.  * 2) define exactly one of
  162.  *    STACKBOTTOM (should be defined to be an expression)
  163.  *    HEURISTIC1
  164.  *    HEURISTIC2
  165.  * If either of the last two macros are defined, then STACKBOTTOM is computed
  166.  * during collector startup using one of the following two heuristics:
  167.  * HEURISTIC1:  Take an address inside GC_init's frame, and round it up to
  168.  *        the next multiple of 16 MB.
  169.  * HEURISTIC2:  Take an address inside GC_init's frame, increment it repeatedly
  170.  *        in small steps (decrement if STACK_GROWS_UP), and read the value
  171.  *        at each location.  Remember the value when the first
  172.  *        Segmentation violation or Bus error is signalled.  Round that
  173.  *        to the nearest plausible page boundary, and use that instead
  174.  *        of STACKBOTTOM.
  175.  *
  176.  * If no expression for STACKBOTTOM can be found, and neither of the above
  177.  * heuristics are usable, the collector can still be used with all of the above
  178.  * undefined, provided one of the following is done:
  179.  * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
  180.  *    without reference to STACKBOTTOM.  This is appropriate for use in
  181.  *    conjunction with thread packages, since there will be multiple stacks.
  182.  *    (Allocating thread stacks in the heap, and treating them as ordinary
  183.  *    heap data objects is also possible as a last resort.  However, this is
  184.  *    likely to introduce significant amounts of excess storage retention
  185.  *    unless the dead parts of the thread stacks are periodically cleared.)
  186.  * 2) Client code may set GC_stackbottom before calling any GC_ routines.
  187.  *    If the author of the client code controls the main program, this is
  188.  *    easily accomplished by introducing a new main program, setting
  189.  *    GC_stackbottom to the address of a local variable, and then calling
  190.  *    the original main program.  The new main program would read something
  191.  *    like:
  192.  *
  193.  *        # include "gc_private.h"
  194.  *
  195.  *        main(argc, argv, envp)
  196.  *        int argc;
  197.  *        char **argv, **envp;
  198.  *        {
  199.  *            int dummy;
  200.  *
  201.  *            GC_stackbottom = (ptr_t)(&dummy);
  202.  *            return(real_main(argc, argv, envp));
  203.  *        }
  204.  *
  205.  *
  206.  * Each architecture may also define the style of virtual dirty bit
  207.  * implementation to be used:
  208.  *   MPROTECT_VDB: Write protect the heap and catch faults.
  209.  *   PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
  210.  */
  211.  
  212.  
  213. # ifdef M68K
  214. #   define MACH_TYPE "M68K"
  215. #   define ALIGNMENT 2
  216. #   ifdef SUNOS
  217. #    define OS_TYPE "SUNOS"
  218.     extern char etext;
  219. #    define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff))
  220. #    define HEURISTIC1    /* differs    */
  221. #   endif
  222. #   ifdef HP
  223. #    define OS_TYPE "HP"
  224.     extern char etext;
  225. #       define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
  226. #       define STACKBOTTOM ((ptr_t) 0xffeffffc)
  227.                   /* empirically determined.  seems to work. */
  228. #   endif
  229. #   ifdef SYSV
  230. #    define OS_TYPE "SYSV"
  231.     extern etext;
  232. #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
  233.                    & ~0x3fffff) \
  234.                   +((word)&etext & 0x1fff))
  235.     /* This only works for shared-text binaries with magic number 0413.
  236.        The other sorts of SysV binaries put the data at the end of the text,
  237.        in which case the default of &etext would work.  Unfortunately,
  238.        handling both would require having the magic-number available.
  239.                       -- Parag
  240.        */
  241. #    define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
  242.             /* The stack starts at the top of memory, but   */
  243.             /* 0x0 cannot be used as setjump_test complains */
  244.             /* that the stack direction is incorrect.  Two  */
  245.             /* bytes down from 0x0 should be safe enough.   */
  246.             /*         --Parag                */
  247. #   endif
  248. # endif
  249.  
  250. # ifdef VAX
  251. #   define MACH_TYPE "VAX"
  252. #   define ALIGNMENT 4    /* Pointers are longword aligned by 4.2 C compiler */
  253.     extern char etext;
  254. #   define DATASTART ((ptr_t)(&etext))
  255. #   ifdef BSD
  256. #    define OS_TYPE "BSD"
  257. #    define HEURISTIC1
  258.             /* HEURISTIC2 may be OK, but it's hard to test. */
  259. #   endif
  260. #   ifdef ULTRIX
  261. #    define OS_TYPE "ULTRIX"
  262. #    define STACKBOTTOM ((ptr_t) 0x7fffc800)
  263. #   endif
  264. # endif
  265.  
  266. # ifdef RT
  267. #   define MACH_TYPE "RT"
  268. #   define ALIGNMENT 4
  269. #   define DATASTART ((ptr_t) 0x10000000)
  270. #   define STACKBOTTOM ((ptr_t) 0x1fffd800)
  271. # endif
  272.  
  273. # ifdef SPARC
  274. #   define MACH_TYPE "SPARC"
  275. #   define ALIGNMENT 4    /* Required by hardware    */
  276.     extern int etext;
  277. #   ifdef SUNOS5
  278. #    define OS_TYPE "SUNOS5"
  279. #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x10003) & ~0x3))
  280.         /* Experimentally determined.              */
  281.         /* Inconsistent with man a.out, which appears    */
  282.         /* to be wrong.                    */
  283. #    define PROC_VDB
  284. #   endif
  285. #   ifdef SUNOS4
  286. #    define OS_TYPE "SUNOS4"
  287. #       define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
  288.         /* On very old SPARCs this is too conservative. */
  289. #    define MPROTECT_VDB
  290. #   endif
  291. #   define HEURISTIC1
  292. # endif
  293.  
  294. # ifdef I386
  295. #   define MACH_TYPE "I386"
  296. #   define ALIGNMENT 4    /* 32-bit compilers align pointers */
  297. #   ifdef SEQUENT
  298. #    define OS_TYPE "SEQUENT"
  299.     extern int etext;
  300. #       define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
  301. #       define STACKBOTTOM ((ptr_t) 0x3ffff000) 
  302. #   endif
  303. #   ifdef SUNOS5
  304. #    define OS_TYPE "SUNOS5"
  305.       extern int etext;
  306. #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x1003) & ~0x3))
  307.     extern int _start();
  308. #    define STACKBOTTOM ((ptr_t)(&_start))
  309. #    define PROC_VDB
  310. #   endif
  311. #   ifdef SCO
  312. #    define OS_TYPE "SCO"
  313. #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
  314.                   & ~0x3fffff) \
  315.                  +((word)&etext & 0xfff))
  316. #    define STACKBOTTOM ((ptr_t) 0x7ffffffc)
  317. #   endif
  318. #   ifdef LINUX
  319. #    define OS_TYPE "LINUX"
  320.     extern int etext;
  321. #       define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
  322. #    define STACKBOTTOM ((ptr_t)0xc0000000)
  323. #   endif
  324. #   ifdef OS2
  325. #    define OS_TYPE "OS2"
  326. #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
  327.                   & ~0x3fffff) \
  328.                  +((word)&etext & 0xfff))
  329.              /* STACKBOTTOM is handled specially in GC_init_inner.    */
  330.         /* OS2 actually has the right system call!        */
  331. #   endif
  332. # endif
  333.  
  334. # ifdef NS32K
  335. #   define MACH_TYPE "NS32K"
  336. #   define ALIGNMENT 4
  337.     extern char **environ;
  338. #   define DATASTART ((ptr_t)(&environ))
  339.                   /* hideous kludge: environ is the first   */
  340.                   /* word in crt0.o, and delimits the start */
  341.                   /* of the data segment, no matter which   */
  342.                   /* ld options were passed through.        */
  343. #   define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
  344. # endif
  345.  
  346. # ifdef MIPS
  347. #   define MACH_TYPE "MIPS"
  348. #   define ALIGNMENT 4    /* Required by hardware    */
  349. #   define DATASTART 0x10000000
  350.                   /* Could probably be slightly higher since */
  351.                   /* startup code allocates lots of junk     */
  352. #   define HEURISTIC2
  353. #   ifdef ULTRIX
  354. #    define OS_TYPE "ULTRIX"
  355. #   endif
  356. #   ifdef RISCOS
  357. #    define OS_TYPE "RISCOS"
  358. #   endif
  359. #   ifdef IRIX5
  360. #    define OS_TYPE "IRIX5"
  361. #    define MPROTECT_VDB
  362. #   endif
  363. # endif
  364.  
  365. # ifdef RS6000
  366. #   define MACH_TYPE "RS6000"
  367. #   define ALIGNMENT 4
  368. #   define DATASTART ((ptr_t)0x20000000)
  369. #   define STACKBOTTOM ((ptr_t)0x2ff80000)
  370. # endif
  371.  
  372. # ifdef HP_PA
  373. #   define MACH_TYPE "HP_PA"
  374. #   define ALIGNMENT 4
  375.     extern int __data_start;
  376. #   define DATASTART ((ptr_t)(&__data_start))
  377. #   define HEURISTIC2
  378. #   define STACK_GROWS_UP
  379. # endif
  380.  
  381. # ifdef ALPHA
  382. #   define MACH_TYPE "ALPHA"
  383. #   define ALIGNMENT 8
  384. #   define DATASTART ((ptr_t) 0x140000000)
  385. #   define HEURISTIC2
  386. #   define CPP_WORDSZ 64
  387. #   define MPROTECT_VDB
  388. # endif
  389.  
  390. # ifndef STACK_GROWS_UP
  391. #   define STACK_GROWS_DOWN
  392. # endif
  393.  
  394. # ifndef CPP_WORDSZ
  395. #   define CPP_WORDSZ 32
  396. # endif
  397.  
  398. # ifndef OS_TYPE
  399. #   define OS_TYPE ""
  400. # endif
  401.  
  402. # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
  403.    -> bad word size
  404. # endif
  405.  
  406. # ifdef PCR
  407. #   undef STACKBOTTOM
  408. #   undef HEURISTIC1
  409. #   undef HEURISTIC2
  410. #   undef PROC_VDB
  411. #   undef MPROTECT_VDB
  412. #   define PCR_VDB
  413. # endif
  414.  
  415. # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
  416. #   define DEFAULT_VDB
  417. # endif
  418.  
  419. # endif
  420.